<template>
    <div>

        <div class="canshu">
          <label for="first_in">ID名:</label>
          <input type="text" id="userId" placeholder="请输入员工首象ID" v-model="userId">
        </div>
        <div class="canshu">
          <label for="next_in">手机号:</label>
          <input type="text" id="phone" placeholder="请输入员工手机"  @input="phcity()" v-model="phone" maxlength="11">
        </div>
         <!-- <div class="canshu">
          <label for="next_in"> 姓名:</label>
          <input type="text" id="phone" placeholder="请填写员工真实姓名" v-model="name">
        </div> -->

        <div class="bombtn">
           <router-link to @click.native="confirm()">提交</router-link>
        </div>
    </div>
</template>

<script>
export default {
    data() {
      return {
        userId: "",
        phone: "",
        name:'',
        min:''
      };
    },
    methods: {
      confirm() {
        if(this.userId==''){
          layer.msg('请输入员工ID')
        }else if(this.phone==''){
      layer.msg('请输入员工手机号')
        }else{
          if(this.min==88){
        console.log(this.userId,this.name)
        this.$http.post(this.APIURL_PREFIX + '/api/wap/companyStaffs?userId='+this.userId+'&'+'phone='+this.phone).then((res) => {
          console.log(res)
          if(res.data.code == 0){
            this.$router.push({ name: 'me_account'})
          }else{
            layer.msg(res.data.msg)
            console.log(res.data.msg);
          }
          
        })
          }else{
            layer.msg('请填写正确格式的手机号')
          }
        
        }
       
      },
      phcity:function(){
        console.log(this.phone.length)
        if(this.phone.length>10){
            console.log(this.phone,this.userId)
            this.$http.get(this.APIURL_PREFIX + '/api/wap/user?id='+this.userId+'&'+'phone='+this.phone).then((res) => {
          console.log(res.data.code)
           layer.msg(res.data.msg)
           if(res.data.code==0){
             this.min=88
           }
          // if(res.data.code == 0){
          //   this.$router.push({ name: 'me_account',query:{}})
          // }else{
          //   layer.msg(res.data.msg)
          //   console.log(res.data.msg);
          // }
          
        })
        }else{

        }
        
      }
    }
}
</script>

<style scoped>
@import "../../assets/personal/css/me_actxinjian.css";
</style>